<!DOCTYPE html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleleaf.org">
<head th:insert="base">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="/back/user/welcome">首页</a>
            <a href="#">竞拍中心</a>
            <a>
              <cite>竞拍列表</cite></a>
          </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <div class="layui-form layui-col-space5">
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" id="goodName"  placeholder="请输入拍品名称" autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-input-inline layui-show-xs-block">
                            <select id="goodType">
                            </select>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input class="layui-input" readonly  autocomplete="off" placeholder="发布开始日期" id="createTimeStart">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input class="layui-input" readonly  autocomplete="off" placeholder="发布截止日期" id="createTimeEnd">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn" id="formSearch"><i class="layui-icon">&#xe615;</i></button>
                        </div>
                    </div>
                </div>
                <div class="layui-card-body ">
                    <table class="layui-hide" id="tableId" lay-filter="tableId"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="operations">
    {{#if(d.auctionStatus == '2'){}}
        <a class="layui-btn layui-btn-xs" lay-event="bid" title="竞价"><i class="layui-icon layui-icon-rmb"></i>竞价</a>
    {{#}}}
    <a class="layui-btn layui-btn-xs layui-btn-warm" lay-event="view" title="查看详情"><i class="layui-icon layui-icon-help"></i>查看详情</a>
</script>
<script th:inline="none">
    layui.use(['table','form','util','tool','laydate','enums','auctionUtil'], function(){
        var table = layui.table;
        var $ = layui.jquery;
        var form = layui.form;
        var util = layui.util;
        var tool = layui.tool;
        var enums = layui.enums;
        var laydate = layui.laydate;
        var baseUrl = "/back/auctionGood";
        var auctionUtil = layui.auctionUtil;
        init_form();
        table.render({
            elem: '#tableId'
            ,id:'tableReload'
            ,url: baseUrl + '/getList'
            ,limit:10
            ,limits:[10,20,50]
            ,method:'post'
            ,toolbar:'#toolbar'
            ,defaultToolbar: ['print']
            ,title: '竞拍列表'
            ,cols: [[
                {field: '', title: '序号',width:50,type:'numbers'}
                ,{field:'goodName', title:'拍品名称',type: 'text',width:200}
                ,{field:'goodDesc', title:'拍品描述',type: 'text',width:400}
                ,{field:'goodNum', title:'拍品数量',type: 'text',width:100}
                ,{field:'startPrice', title:'起拍价',type: 'text',width:100}
                ,{field:'bidNum', title:'竞拍次数',type: 'text',width:100, sort: true}
                ,{field:'maxPrice', title:'最高竞价',type: 'text',width:100, sort: true}
                ,{field:'auctionStatusDesc', title:'竞拍状态',type: 'text',width:100}
                ,{field:'goodsTypeName', title:'拍品类别',type: 'text',width:100}
                ,{field:'endTime', title:'竞拍结束时间 ',type: 'text',width:200,templet:function (d) {
                        if(d.endTime){
                            return util.toDateString(d.endTime, "yyyy-MM-dd HH:mm:ss")
                        }
                        return "";
                    }, sort: true}
                ,{field:'createTime', title:'发布时间',type: 'text',width:200,templet:function (d) {
                        if(d.createTime){
                            return util.toDateString(d.createTime, "yyyy-MM-dd HH:mm:ss")
                        }
                        return "";
                    }, sort: true}
                ,{title:'操作', toolbar: '#operations',width:300}
            ]]
            ,page: true
        });

        //行工具栏事件
        table.on('tool(tableId)', function(obj){
            var data = obj.data;
            switch (obj.event) {
                case 'bid':
                    xadmin.open('参与竞价','/back/bidRecord/add?id='+data.id,400,300);
                    break;
                case 'view':
                    xadmin.open('拍品详情',baseUrl + '/view?id='+data.id);
                    break;
            }
        });
        //条件查询
        $('#formSearch').on('click', function(){
            table.reload('tableReload', {
                page: {curr: 1 }
                ,where:  getQueryParams()
            });
        });

        /**
         * 查询的参数
         * @returns {{}}
         */
        function getQueryParams() {
            return {
                goodName:$("#goodName").val().trim()
                ,goodType:$("#goodType").val().trim()
                ,auctionStatus:$("#auctionStatus").val().trim()
                ,createTimeStart:$("#createTimeStart").val().trim()
                ,createTimeEnd:$("#createTimeEnd").val().trim()
            }
        }

        /**
         * 初始化页面
         */
        function init_form() {
            auctionUtil.createGoodType('goodType',null,'请选择拍品类别');
            enums.createSelectByEnum('auctionStatus','EnumAuctionStatus',null,null,'请选择竞拍状态');
            form.render();
            laydate.render({
                elem: '#createTimeStart'
                ,type: 'datetime'
            });
            laydate.render({
                elem: '#createTimeEnd'
                ,type: 'datetime'
            });
        }

    });
</script>
</body>
</html>